﻿<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory">Chapter 15. Compiler Reference</title>
	<link rel="stylesheet" href="css/espertech.css" type="text/css">
	<meta xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" name="generator" content="DocBook XSL-NS Stylesheets V1.74.0">
	<meta xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="home" href="index.html" title="Esper Reference">
	<link rel="up" href="index.html" title="Esper Reference">
	<link rel="prev" href="epl-views.html" title="Chapter 14. EPL Reference: Data Windows">
	<link rel="next" href="apiruntime.html" title="Chapter 16. Runtime Reference">
</head>

<body>
	<p xmlns:d="http://docbook.org/ns/docbook" id="title"><a href="./index.html" class="site_href"><strong>www.espertech.com</strong></a><a href="http://www.espertech.com/esper/esper-documentation/" class="doc_href"><strong>Documentation</strong></a></p>
	<ul xmlns:d="http://docbook.org/ns/docbook" class="docnav">
		<li class="previous"><a accesskey="p" href="epl-views.html"><strong>Prev</strong></a></li>
		<li class="next"><a accesskey="n" href="apiruntime.html"><strong>Next</strong></a></li>
	</ul>
	<div class="chapter" lang="en-US">
		<div class="titlepage">
			<div>
				<div>
					<h2 class="title"><a id="apicompiler"></a>Chapter 15. Compiler Reference</h2>
				</div>
			</div>
		</div>
		<div class="toc">
			<dl>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-intro">15.1. Introduction</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-concepts">15.2. Concepts</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-concepts-module">15.2.1. Module</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-concepts-eplobjects">15.2.2. EPL-objects</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-concepts-dependencies">15.2.3. Dependencies</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-concepts-dependencyresolve">15.2.4. Dependency Resolution</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-concepts-accessmodifier">15.2.5. Access Modifiers</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-concepts-eventbus">15.2.6. Bus Modifier for Event Types</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-compile">15.3. Compiling a Module</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-compiledio">15.4. Reading and Writing a Compiled Module</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-readingmodule">15.5. Reading Module Content</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-compilerarguments">15.6. Compiler Arguments</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-compilerarguments-configuration">15.6.1. Compiler Configuration</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-compilerarguments-path">15.6.2. Compiler Path</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-compilerarguments-options">15.6.3. Compiler Options</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-compilerarguments-pathcache">15.6.4. Compiler Path Cache</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-soda">15.7. Statement Object Model</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-soda-buildingstep1">15.7.1. Building an Object Model</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-soda-buildingstep2">15.7.2. Building Expressions</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-soda-buildingstep3">15.7.3. Building a Pattern Statement</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-soda-buildingstep4">15.7.4. Building a Select Statement</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-soda-buildingstep5">15.7.5. Building a Create-Variable and On-Set Statement</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#api-soda-building-step6">15.7.6. Building Create-Window, On-Delete and On-Select Statements</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-substitution">15.8. Substitution Parameters</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-osgi">15.9. OSGi, Class Loader, Class-For-Name</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-authoring">15.10. Authoring Tools</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-testing">15.11. Testing Tools</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#devlifecycle-debugging">15.12. Debugging</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="apicompiler.html#devlifecycle-debugging-audit">15.12.1. @Audit Annotation</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-deploymentorder">15.13. Ordering Multiple Modules</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-logging">15.14. Logging</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-debugging">15.15. Debugging Generated Code</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-version">15.16. Compiler Version and Runtime Version</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-optimizations">15.17. Compiler Byte Code Optimizations</a></span></dt>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-filterplan">15.18. Compiler Filter Expression Analysis</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-filterplan-constituentanalysis">15.18.1. Constituent Analysis</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-filterplan-hintvaluecomposite">15.18.2. Value Composite Expression Analysis</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-filterplan-hintlkupcomposite">15.18.3. Lookupable Composite Expression Analysis</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-filterplan-hintrebool">15.18.4. Boolean Reusable Expression Analysis</a></span></dt>
						<dt><span class="sect2"><a href="apicompiler.html#apicompiler-filterplan-condition">15.18.5. Condition Analysis and Planning</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="apicompiler.html#apicompiler-limitations">15.19. Limitations</a></span></dt>
			</dl>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-intro"></a>15.1. Introduction</h2>
					</div>
				</div>
			</div>
			<p>
				The compiler provides the following functions:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						<p>Compiles a module to JVM byte code.</p>
					</li>
					<li>
						<p>Compiles a fire-and-forget query to JVM byte code.</p>
					</li>
					<li>
						<p>Parses a module producing a module object model.</p>
					</li>
					<li>
						<p>Parses a statement producing a statement object model.</p>
					</li>
					<li>
						<p>Validates the syntax of a module.</p>
					</li>
					<li>
						<p>Reads a module from external sources.</p>
					</li>
				</ul>
			</div>
			<p>
				The most important function of the compiler is to produce byte code for your module. Deploy the byte code into a runtime for execution.
			</p>
			<p>
				The compiler interface is <code class="literal">EPCompiler</code> in package <code class="literal">com.espertech.esper.compiler.client</code>.
				Your application obtains a compiler instance by calling the <code class="literal">getCompiler</code> method of <code class="literal">EPCompilerProvider</code>.
			</p>
			<p>
				For example:
			</p>
			<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPCompiler epCompiler = EPCompilerProvider.getCompiler();</pre>
			<p>
				Use the compiler as follows:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						<p>The compiler is a stateless service. It does not have any state that it keeps between calls.</p>
					</li>
					<li>
						<p>You may obtain and use any number of compiler instances in parallel.</p>
					</li>
					<li>
						<p>You may share a compiler instance between threads.</p>
					</li>
					<li>
						<p>All compiler methods are thread-safe.</p>
					</li>
					<li>
						<p>The compiler internally uses multiple threads for compiling each statement in parallel, for modules that have multiple statements.</p>
					</li>
				</ul>
			</div>
			<div xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
				<h2>Tip</h2>
				<p>When using the compiler in separate threads, make sure the input to the compiler does not get modified while the compiler is using it. For example, the application should not modify compiler configuration or compiler path at the same time as invoking a compiler method.</p>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-concepts"></a>15.2. Concepts</h2>
					</div>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-concepts-module"></a>15.2.1. Module</h3>
						</div>
					</div>
				</div><a id="d0e39809" class="indexterm"></a><a id="d0e39814" class="indexterm"></a>
				<p>
					A module contains zero, one or multiple statements. A module is a source code unit as the compiler turns a module into byte code.
					A module does not need to be a text - a module can also be an object model.
				</p>
				<p>
					In module text, statements appear separated by the semicolon (;) character. If there is a single statement in the module the semicolon can be left off.
				</p>
				<p>
					The synopsis of a module file is:
				</p>
				<pre class="synopsis">[module <span class="emphasis"><em>module_name</em></span>;]
	[uses <span class="emphasis"><em>module_name</em></span>; | import <span class="emphasis"><em>import_name</em></span>;] [uses <span class="emphasis"><em>module_name</em></span>; | import <span class="emphasis"><em>import_name</em></span>;] [...]
	[<span class="emphasis"><em>epl_statement</em></span>;] [<span class="emphasis"><em>epl_statement</em></span>;] [...]</pre>
				<p>
					Use the <code class="literal">module</code> keyword followed a <span class="emphasis"><em>module_name</em></span> identifier or a package (identifiers separated by dots) to declare the name of the module. The module name declaration must be at the beginning of the file, comments and whitespace excluded. The module name
					serves to check uses-dependences of other modules.
				</p>
				<p>
					If a module file requires certain constructs that may be shared by other modules, such as named windows, tables, variables, event types, variant streams or inserted-into streams required by statements,
					a module file may specify dependent modules with the <code class="literal">uses</code> keyword. It can be used to avoid name conflicts and automatic deployment can use this information to determine deployment order.
				</p>
				<p>
					If the statements in the module require Java classes such as for underlying events or user-defined functions, use the <code class="literal">import</code> keyword followed by the fully-qualified class name or package name in the format <code class="literal">package.*</code>.
					The <code class="literal">uses</code> and <code class="literal">import</code> keywords are optional and must occur after the <code class="literal">module</code> declaration.
				</p>
				<p>
					Following the optional deployment instructions are any number of <span class="emphasis"><em>epl_statement</em></span> statements that are separated by semicolon (<code class="literal">;</code>).
				</p>
				<p>
					The following is a sample module file explained in detail thereafter:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">// Declare the name for the module (optional).
module org.myorganization.switchmonitor;

// Declare other module(s) that this module depends on (optional).
// This can be used to resolve name conflicts.
uses org.myorganization.common;

// Import any Java/.NET classes of the given package name (optional). 
// Imports only handle classpath and do not import other modules.
import org.myorganization.events.*;

// Declare an event type based on a Java class in the package that was imported as above
create schema MySwitchEvent as MySwitchEventPOJO;

// Sample statement
@Name('Off-On-Detector')
insert into MyOffOnStream
select * from pattern[every-distinct(id) a=MySwitchEvent(status='off') 
  -&gt; b=MySwitchEvent(id=a.id, status='on')];

// Sample statement
@Name('Count-Switched-On')
@Description('Count per switch id of the number of Off-to-On switches in the last 1 hour')
select id, count(*) from MyOffOnStream#time(1 hour) group by id;</pre>
				<p>
					The example above declares a module name of <code class="literal">org.myorganization.switchmonitor</code>.
					The example demonstrates the <code class="literal">import</code> keyword to make a package name known to the compiler for resolving classpath items, as the example assumes that <code class="literal">MySwitchEventPOJO</code> is a POJO event class.
					In addition the example module contains two statements separated by semicolon characters.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-concepts-eplobjects"></a>15.2.2. EPL-objects</h3>
						</div>
					</div>
				</div>
				<p>
					The following types of <span class="emphasis"><em>EPL-objects</em></span> are managed by the compiler and runtime:
				</p>
				<div class="itemizedlist">
					<ul compact="compact">
						<li>
							<p><span class="emphasis"><em>Event types</em></span> define stream type information and are added using <code class="literal">create schema</code> or by configuration.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Variables</em></span> are free-form value holders and are added using <code class="literal">create variable</code> or by configuration.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Named windows</em></span> are sharable named data windows and are added using <code class="literal">create window</code>.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Tables</em></span> are sharable organized rows with columns that are simple, aggregation and complex types, and are added using <code class="literal">create table</code>.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Contexts</em></span> define analysis lifecycle and are added using <code class="literal">create context</code>.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Expressions</em></span> and <span class="emphasis"><em>Scripts</em></span> are reusable expressions and are added using <code class="literal">create expression</code>.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Inlined-Classes</em></span> are classes in Java (or C# for NEsper) that are part of the EPL code and are added using <code class="literal">create inlined_class</code>.</p>
						</li>
						<li>
							<p><span class="emphasis"><em>Indexes</em></span> organize named window events and table rows for fast lookup and are added using <code class="literal">create index</code>.</p>
						</li>
					</ul>
				</div>
				<p>
					Your application can pre-configure event types and variables in a <code class="literal">Configuration</code> object.
				</p>
				<p>
					A module can create any number of EPL-objects.
				</p>
				<p>
					A module can depend on EPL-objects that are pre-configured or other modules created.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-concepts-dependencies"></a>15.2.3. Dependencies</h3>
						</div>
					</div>
				</div>
				<p>
					A module usually depends on event types and may also depend on other EPL-objects such as named windows or tables, for example.
					The compiler resolves all dependencies at compile-time. It produces byte code based on the information associated with the EPL-object.
					Upon deploying a compiled module's byte code into the runtime the runtime validates that dependencies exist.
				</p>
				<p>
					For example, consider the following module:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select accountId, amount from Withdrawal</pre>
				<p>
					The module above depends on the event type <code class="literal">Withdrawal</code>. The compiler resolves the event type name to an <code class="literal">EventType</code> instance.
					It produces code according to the event type. At time of deployment of the compiled module the runtime verifies that the <code class="literal">Withdrawal</code> event type exists.
				</p>
				<p>
					Specifically, the compiler generates code like this:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>If the <code class="literal">Withdrawal</code> event type is a Map-based event type, the compiler produces code such as <code class="literal">event.get("accountId")</code>.</p>
						</li>
						<li>
							<p>If the <code class="literal">Withdrawal</code> event type is an Object-Array-based event type, the compiler produces code such as <code class="literal">event[index]</code>.</p>
						</li>
						<li>
							<p>If the <code class="literal">Withdrawal</code> event type is a Bean-based event type, the compiler produces code such as <code class="literal">event.getAccountId()</code>.</p>
						</li>
					</ul>
				</div>
				<div xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="note">
					<h2>Note</h2>
					<p>
						The compiler only tracks dependencies on EPL-objects.
					</p>
					<p>
						The compiler does not track classpath dependencies. The runtime does not validate classpath dependencies.
					</p>
					<p>
						The runtime validates that EPL-object dependencies exist before deploying a compiled module.
					</p>
					<p>
						The runtime does not validate that the information about the EPL-object is the same as at compile-time.
					</p>
				</div>
				<p>
					In other words, the runtime does not validate that event property names, event property types, table column names and types, variable types, index property names and other compile-time information matches the information that was provided at compile time.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-concepts-dependencyresolve"></a>15.2.4. Dependency Resolution</h3>
						</div>
					</div>
				</div>
				<p>
					The compiler resolves an EPL-object by its name by looking at:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>The EPL-objects created by the same module (also known as <code class="literal">local</code>)</p>
						</li>
						<li>
							<p>The EPL-objects created by the other modules (also known as <code class="literal">path</code>).</p>
						</li>
						<li>
							<p>The pre-configured event types and variables.</p>
						</li>
					</ul>
				</div>
				<p>
					The term <span class="emphasis"><em>path</em></span> encompasses the EPL-objects other modules define.
					The term <span class="emphasis"><em>local</em></span> encompasses the EPL-objects the same module defines.
				</p>
				<p>
					Coming back to the previous example:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select accountId, amount from Withdrawal</pre>
				<p>
					The compiler finds an event type by name <code class="literal">Withdrawal</code> by:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Checking whether <code class="literal">Withdrawal</code> is an event type that the same module defined by <code class="literal">create schema</code> (local).</p>
						</li>
						<li>
							<p>Checking whether <code class="literal">Withdrawal</code> is an event type that another modules defined by <code class="literal">create schema</code> (path).</p>
						</li>
						<li>
							<p>Checking whether <code class="literal">Withdrawal</code> is a pre-configured event type.</p>
						</li>
					</ul>
				</div>
				<p>
					In case the name cannot be resolved the compilation fails.
				</p>
				<p>
					In case the name is found multiple times, the compiler checks as follows:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>If the name is a pre-configured EPL-object and the name is also found in path the validation fails.</p>
						</li>
						<li>
							<p>If the name is found in local, and the name is found in path or preconfigured, the validation fails.</p>
						</li>
						<li>
							<p>If the name is found in path for multiple modules, and if there is no module-uses provided, the validation fails.</p>
						</li>
						<li>
							<p>If the name is found in path for multiple modules and there are module-uses module names provided the EPL object module name must match one of the module names in module-uses.</p>
						</li>
					</ul>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-concepts-accessmodifier"></a>15.2.5. Access Modifiers</h3>
						</div>
					</div>
				</div>
				<p>
					Access level modifiers determine whether other modules can use a particular EPL-object.
				</p>
				<p>
					An EPL-object may be declared with the modifier public, in which case that EPL-object is visible to all other modules.
				</p>
				<p>
					An EPL-object may be declared with the modifier protected, in which case that EPL-object is visible to other modules that have the same module name.
				</p>
				<p>
					An EPL-object may be declared with the modifier private (the default), in which case that EPL-object is not visible to other modules.
				</p>
				<p>
					Your application may set access modifiers by:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Using an annotation i.e. <code class="literal">@public</code>, <code class="literal">@protected</code>, <code class="literal">@private</code>.</p>
						</li>
						<li>
							<p>Setting default access modifiers in the <code class="literal">ConfigurationCompilerByteCode</code> that is part of the <code class="literal">Configuration</code> object.</p>
						</li>
						<li>
							<p>Computing access modifiers by providing a callback in <code class="literal">CompilerOptions</code> compiler options. Any computed value overrides the annotation or configuration default.</p>
						</li>
					</ul>
				</div>
				<p>
					The following module declares a public named window to hold the last 10 seconds of withdrawal events:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@public create window WithdrawalWindow#time(10) as Withdrawal</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-concepts-eventbus"></a>15.2.6. Bus Modifier for Event Types</h3>
						</div>
					</div>
				</div>
				<p>
					For event types there is a <code class="literal">bus</code> modifier that determines whether or not the event type is available for use with the <code class="literal">sendEvent<span class="emphasis"><em>Type</em></span></code> methods of the <code class="literal">EPEventService</code> runtime event service.
				</p>
				<p>
					An event type may be declared with the bus modifier, in which case calls to <code class="literal">sendEvent<span class="emphasis"><em>Type</em></span></code> process the event.
				</p>
				<p>
					An event type may be declared with the non-bus modifier (the default), in which case calls to <code class="literal">sendEvent<span class="emphasis"><em>Type</em></span></code> cause an exception to be thrown.
				</p>
				<p>
					To understand this better, here is what <code class="literal">sendEvent<span class="emphasis"><em>Type</em></span></code> of <code class="literal">EPEventService</code> does:
					When your application calls any of the <code class="literal">sendEventBean</code>, <code class="literal">sendEventMap</code>, <code class="literal">sendEventObjectArray</code>, <code class="literal">sendEventJson</code>,
					<code class="literal">sendEventXMLDOM</code> or <code class="literal">sendEventAvro</code> methods of <code class="literal">EPEventService</code>, the runtime finds the event type using the event type name that is passed.
					It associates the event type to the event object for processing the given event. If the event type name is not recognized or the event type does not have the bus modifier it throws an exception.
				</p>
				<p>
					The bus modifier is not required for pre-configured event types. The bus modifier requires public access.
				</p>
				<p>
					Your application may set the bus modifier by:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Using the <code class="literal">@buseventtype</code> annotation.</p>
						</li>
						<li>
							<p>Setting the default bus modifier in the <code class="literal">ConfigurationCompilerByteCode</code> that is part of the <code class="literal">Configuration</code> object.</p>
						</li>
						<li>
							<p>Computing a bus modifier by providing a callback in <code class="literal">CompilerOptions</code> compiler options. Any computed value overrides the annotation or configuration default.</p>
						</li>
					</ul>
				</div>
				<p>
					The following module declares a public event type that allows an application to send in events of that name:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@public @buseventtype create schema AccountQueryEvent (accountId string)</pre>
				<p>
					The information herein pertains to the <code class="literal">routeEvent<span class="emphasis"><em>Type</em></span></code> and <code class="literal">EventSender</code> as well.
				</p>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-compile"></a>15.3. Compiling a Module</h2>
					</div>
				</div>
			</div>
			<p>
				The <code class="literal">compile</code> method takes two parameters. The first parameter is the module text or an module object model. The second parameter are compiler arguments.
			</p>
			<p>
				The output of the compiler is an <code class="literal">EPCompiled</code> instance. You can deploy <code class="literal">EPCompiled</code> instances directly into a runtime as described in <a class="xref" href="apiruntime.html#apiruntime-deployment" title="16.4. Deploying and Undeploying Using EPDeploymentService">Section 16.4, “Deploying and Undeploying Using EPDeploymentService”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-compiledio"></a>15.4. Reading and Writing a Compiled Module</h2>
					</div>
				</div>
			</div>
			<p>
				The <code class="literal">EPCompiledIOUtil</code> class is a utility for writing and reading <code class="literal">EPCompiled</code> instances to and from jar-files:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						<p>Write an <code class="literal">EPCompiled</code> instance to a jar file.</p>
					</li>
					<li>
						<p>Read a jar file previously written by <code class="literal">EPCompiledIOUtil</code> and return an <code class="literal">EPCompiled</code> instance.</p>
					</li>
				</ul>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-readingmodule"></a>15.5. Reading Module Content</h2>
					</div>
				</div>
			</div>
			<p>
				Read and parse module files using the <code class="literal">readModule</code> and <code class="literal">parseModule</code> methods, which return a <code class="literal">Module</code> instance to represent the module information.
			</p>
			<p>
				This code snippet demonstrates reading and parsing a module given a file name:
			</p>
			<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">Module module = EPCompilerProvider.getCompiler().read(new File("switchmonitor.epl"));</pre>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-compilerarguments"></a>15.6. Compiler Arguments</h2>
					</div>
				</div>
			</div>
			<p>
				The compiler arguments are:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						<p>The <code class="literal">Configuration</code> object can provide pre-configured event types and variables as well as other compiler settings.</p>
					</li>
					<li>
						<p>The <code class="literal">CompilerPath</code> passes information that the compiler uses to determine the EPL-objects that the module may depend on.</p>
					</li>
					<li>
						<p>The <code class="literal">CompilerOptions</code> are compiler instructions.</p>
					</li>
				</ul>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-compilerarguments-configuration"></a>15.6.1. Compiler Configuration</h3>
						</div>
					</div>
				</div>
				<p>
					Pass a <code class="literal">Configuration</code> instance to the compiler to configure the compiler. By default the compiler uses an empty configuration object.
				</p>
				<p>
					The compiler only uses the common section and the compiler section of the configuration. The compiler ignores the runtime section of the configuration.
				</p>
				<p>
					It is not necessary to pass a configuration object or to pre-configure event types. You may create event types by means of <code class="literal">create schema</code>.
				</p>
				<p>
					A pre-configured event types is a convenience since the event type is already defined and ready to use.
					The common section of the configuration holds the pre-configured event types. The following sample adds a pre-configured <code class="literal">WithdrawalEvent</code> map-based event type:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">Map&lt;String, Object&gt; columns = new LinkedHashMap&lt;&gt;();
columns.put("accountId", String.class);
columns.put("amount", double.class);

Configuration configuration = new Configuration();
configuration.getCommon().addEventType("WithdrawalEvent", columns);
CompilerArguments args = new CompilerArguments(configuration);</pre>
				<p>
					To obtain a configuration object from a runtime call <code class="literal">getConfigurationDeepCopy</code> on <code class="literal">EPRuntime</code>:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">Configuration configuration = epRuntime.getConfigurationDeepCopy();
CompilerArguments args = new CompilerArguments(configuration);</pre>
				<p>
					More information on the common and compiler configuration can be found at <a class="xref" href="configuration.html" title="Chapter 17. Configuration">Chapter 17, <i>Configuration</i></a>.
				</p>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-compilerarguments-configuration-subscriber"></a>15.6.1.1. Configuring the Compiler for Subscribers</h4>
							</div>
						</div>
					</div>
					<p>
						By default the compiler does not generate code for subscribers and the <code class="literal">setSubscriber</code> method on <code class="literal">EPStatement</code> throws an exception.
					</p>
					<p>
						You may set the <code class="literal">allowSubscriber</code> option:
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">Configuration configuration = new Configuration();
configuration.getCompiler().getByteCode().setAllowSubscriber(true);
CompilerArguments args = new CompilerArguments(configuration);</pre>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-compilerarguments-path"></a>15.6.2. Compiler Path</h3>
						</div>
					</div>
				</div>
				<p>
					The compiler path provides EPL-objects that other modules may declare and that the current module may use.
				</p>
				<p>
					For example, assume a module <code class="literal">M<sub>1</sub></code> that declares a named window <code class="literal">WithdrawalWindow</code>:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@public create window WithdrawalWindow#time(10) as Withdrawal</pre>
				<p>
					A second module <code class="literal">M<sub>2</sub></code> may query the named window like so:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select (select count(*) from WithdrawalWindow) as cnt from Withdrawal</pre>
				<p>
					Module <code class="literal">M<sub>2</sub></code> depends on the EPL-object <code class="literal">WithdrawalWindow</code> (a named window) that module <code class="literal">M<sub>1</sub></code> declares.
				</p>
				<p>
					You can build a path from:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							An existing runtime. This adds all EPL-objects that are currently deployed into the runtime to the path.
						</li>
						<li>
							Compiled modules.
						</li>
					</ul>
				</div>
				<p>
					Assume that your application compiled module <code class="literal">M<sub>1</sub></code> like so:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">Map&lt;String, Object&gt; columns = new LinkedHashMap&lt;&gt;();
columns.put("accountId", String.class);
columns.put("amount", double.class);

Configuration configuration = new Configuration();
configuration.getCommon().addEventType("WithdrawalEvent", columns);

CompilerArguments arguments = new CompilerArguments(configuration);
EPCompiled compiledModuleM1 = EPCompilerProvider.getCompiler().compile("@public create window WithdrawalWindow#time(10) as Withdrawal", arguments);</pre>
				<p>
					The <code class="literal">compiledModuleM1</code> instance holds the byte code of module <code class="literal">M<sub>1</sub></code>.
				</p>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-compilerarguments-path-runtime"></a>15.6.2.1. Compiling Against a Runtime</h4>
							</div>
						</div>
					</div>
					<p>
						After deploying compiled modules to a runtime, the compiler can build the path from the runtime.
					</p>
					<p>
						The <code class="literal">getRuntimePath</code> method of <code class="literal">EPRuntime</code> returns the path object for use by the compiler. The path object is an instance of <code class="literal">EPCompilerPathable</code>.
					</p>
					<p>
						The <code class="literal">add</code> method of <code class="literal">CompilerPath</code> accepts a <code class="literal">EPCompilerPathable</code> instance provided by a runtime.
					</p>
					<p>
						For example, as follows:
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">Map&lt;String, Object&gt; columns = new LinkedHashMap&lt;&gt;();
columns.put("accountId", String.class);
columns.put("amount", double.class);

Configuration configuration = new Configuration();
configuration.getCommon().addEventType("WithdrawalEvent", columns);

// Get a runtime
EPRuntime runtime = EPRuntimeProvider.getDefaultRuntime(configuration);
runtime.getDeploymentService().deploy(compiledModuleM1);

// Compile another module
CompilerArguments arguments = new CompilerArguments(configuration);
arguments.getPath().add(runtime.getRuntimePath());
EPCompiled compiledModuleM2 = EPCompilerProvider.getCompiler().compile("select (select count(*) from WithdrawalWindow) as cnt from Withdrawal", arguments);</pre>
				</div>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-compilerarguments-path-module"></a>15.6.2.2. Adding a Compiled Module to Path</h4>
							</div>
						</div>
					</div>
					<p>
						Use the <code class="literal">addPath</code> method of <code class="literal">CompilerPath</code> to add a compiled module to path.
					</p>
					<p>
						For example, as follows:
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">CompilerArguments arguments = new CompilerArguments(configuration);
arguments.getPath().add(compiledModuleM1);
EPCompiled compiledModuleM2 = EPCompilerProvider.getCompiler().compile("select (select count(*) from WithdrawalWindow) as cnt from Withdrawal", arguments);</pre>
					<div xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
						<h2>Tip</h2>
						<p>Use a path cache when there are many compiled modules in the path, see <a class="xref" href="apicompiler.html#apicompiler-compilerarguments-pathcache" title="15.6.4. Compiler Path Cache">Section 15.6.4, “Compiler Path Cache”</a>.</p>
					</div>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-compilerarguments-options"></a>15.6.3. Compiler Options</h3>
						</div>
					</div>
				</div>
				<p>
					Compiler options provide compiler callbacks and other compile-time parameters:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Provide or override access modifiers and bus event type modifier.</p>
						</li>
						<li>
							<p>Provide or override the statement name.</p>
						</li>
						<li>
							<p>Provide a statement user object and that can be obtained from an <code class="literal">EPStatement</code> with <code class="literal">getUserObjectCompileTime</code>.</p>
						</li>
						<li>
							<p>Provide or override the module name.</p>
						</li>
						<li>
							<p>Provide or override module-uses information.</p>
						</li>
						<li>
							<p>Receive Janino class-level compiler output for inlined-classes for example for use with black-listing or white-listing classes based on class constant pool information.</p>
						</li>
					</ul>
				</div>
				<p>
					Please consult the JavaDoc for more information.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-compilerarguments-pathcache"></a>15.6.4. Compiler Path Cache</h3>
						</div>
					</div>
				</div>
				<p>
					The path cache is not used by default and can optionally be set. It is only for use when your application adds compiled modules (<code class="literal">EPCompiled</code> instances) to the path as described in <a class="xref" href="apicompiler.html#apicompiler-compilerarguments-path-module" title="15.6.2.2. Adding a Compiled Module to Path">Section 15.6.2.2, “Adding a Compiled Module to Path”</a>.
				</p>
				<p>
					The compiler is a stateless service and does not retain any information between calls. It therefore does not know, for each of the <code class="literal">EPCompiled</code> instances in the path, the visible EPL objects that the <code class="literal">EPCompiled</code> in the path provides.
					The path cache retains this information so that subsequent calls to the compiler do not need to inspect each <code class="literal">EPCompiled</code> in the path.
				</p>
				<p>
					Use <code class="literal">CompilerPathCache.getInstance()</code> and the <code class="literal">setPathCache</code> method of <code class="literal">CompilerOptions</code> to use a path cache. A path cache is thread-safe.
				</p>
				<p>
					Obtain the path cache as follows:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">// Obtain path cache for reuse when compiling modules
CompilerPathCache pathCache = CompilerPathCache.getInstance();</pre>
				<p>
					Set the path cache like so:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">arguments.getOptions().setPathCache(pathCache);</pre>
				<p>
					The compiler automatically adds the current <code class="literal">EPCompiled</code> output and all <code class="literal">EPCompiled</code> instances in path to the cache.
				</p>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-soda"></a>15.7. Statement Object Model</h2>
					</div>
				</div>
			</div><a id="d0e40615" class="indexterm"></a>
			<p>
				The statement object model is a set of classes that provide an object-oriented representation of statement. The object model classes are found in package <code class="literal">com.espertech.esper.common.client.soda</code>. An instance of <code class="literal">EPStatementObjectModel</code> represents a statement's object model.
			</p>
			<p>
				The statement object model classes are a full and complete specification of a statement. All EPL constructs including expressions and sub-queries are available in the statement object model.
			</p>
			<p>
				The statement object model provides the means to building, changing or interrogating statements beyond the string representation. The object graph of the statement object model is fully navigable for easy querying by code, and is also serializable allowing applications to persist or transport statements in object form, when required.
			</p>
			<p>
				The statement object model supports full round-trip from object model to statement string and back to object model: A statement object model can be rendered into a string representation via the <code class="literal">toEPL</code> method on <code class="literal">EPStatementObjectModel</code>. Further, the compiler API allows compiling a statement string into an object model representation via the <code class="literal">eplToModel</code> method on <code class="literal">EPCompiler</code>.
			</p>
			<p>
				The statement object model is fully mutable. Mutating any list such as returned by <code class="literal">getChildren()</code>, for example, is acceptable and supported.
			</p>
			<p>
				The following limitations apply:
			</p>
			<div class="itemizedlist">
				<ul compact="compact">
					<li>
						<p>
							Statement object model classes are not safe for sharing between threads other than for read access.
						</p>
					</li>
					<li>
						<p>
							Between versions the serialized form of the object model is subject to change. There are no guarantees that the serialized object model of one version will be fully compatible with the
							serialized object model generated by another version. Please consider this issue when storing object models in persistent store.
						</p>
					</li>
				</ul>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-soda-buildingstep1"></a>15.7.1. Building an Object Model</h3>
						</div>
					</div>
				</div>
				<p>
					A <code class="literal">EPStatementObjectModel</code> consists of an object graph representing all possible clauses that can be part of a statement.
				</p>
				<p>
					Among all clauses, the <code class="literal">SelectClause</code> and <code class="literal">FromClause</code> objects are required clauses that must be present, in order to define what to select and where to select from.
				</p>
				<div class="table"><a id="soda-building-classes-1"></a>
					<p class="title"><b>Table 15.1. Required Statement Object Model Instances</b></p>
					<div class="table-contents">
						<table summary="Required Statement Object Model Instances" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Class</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td><span class="emphasis"><em>EPStatementObjectModel</em></span></td>
									<td>All statement clauses for a statement, such as the select-clause and the from-clause, are specified within the object graph of an instance of this class</td>
								</tr>
								<tr>
									<td><span class="emphasis"><em>SelectClause</em></span></td>
									<td>A list of the selection properties or expressions, or a wildcard</td>
								</tr>
								<tr>
									<td><span class="emphasis"><em>FromClause</em></span></td>
									<td>A list of one or more streams; A stream can be a filter-based, a pattern-based, SQL-based and other; Add data windows here.</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Part of the statement object model package are convenient builder classes that make it easy to build a new object model or change an existing object model. The <code class="literal">SelectClause</code> and <code class="literal">FromClause</code> are such builder classes and provide convenient <code class="literal">create</code> methods.
				</p>
				<p>
					Within the from-clause you have a choice of different streams to select on. The <code class="literal">FilterStream</code> class represents a stream that is filled by events of a certain type and that pass an optional filter expression.
				</p>
				<p>
					We can use the classes introduced above to create a simple statement object model:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setSelectClause(SelectClause.createWildcard());
model.setFromClause(FromClause.create(FilterStream.create("ReadyEvent")));</pre>
				<p>
					The model as above is equivalent to:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from ReadyEvent</pre>
				<p>
					Notes on usage:
				</p>
				<div class="itemizedlist">
					<ul compact="compact">
						<li>
							<p>
								Variable names can simply be treated as property names.
							</p>
						</li>
						<li>
							<p>
								When selecting from named windows or tables, the name of the named window or table is the event type name for use in <code class="literal">FilterStream</code> instances or patterns.
							</p>
						</li>
						<li>
							<p>
								To compile an arbitrary sub-expression text into an <code class="literal">Expression</code> object representation, simply add the expression text to a <code class="literal">where</code> clause,
								compile the EPL string into an object model via the <code class="literal">eplToModel</code> method on <code class="literal">EPCompiler</code>, and obtain the compiled <code class="literal">where</code>
								from the <code class="literal">EPStatementObjectModel</code> via the <code class="literal">getWhereClause</code> method.
							</p>
						</li>
					</ul>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-soda-buildingstep2"></a>15.7.2. Building Expressions</h3>
						</div>
					</div>
				</div>
				<p>
					The <code class="literal">EPStatementObjectModel</code> includes an optional where-clause. The where-clause is a filter expression that the runtime applies to events in one or more streams. The key interface for all expressions is the <code class="literal">Expression</code> interface.
				</p>
				<p>
					The <code class="literal">Expressions</code> class provides a convenient way of obtaining <code class="literal">Expression</code> instances for all possible expressions. Please consult the JavaDoc for detailed method information.
					The next example discusses sample where-clause expressions.
				</p>
				<p>
					Use the <code class="literal">Expressions</code> class as a service for creating expression instances, and add additional expressions via the <code class="literal">add</code> method that most expressions provide.
				</p>
				<p>
					The next example adds a simple where-clause to the EPL as shown earlier:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from ReadyEvent where line=8</pre>
				<p>
					And the code to add a where-clause to the object model is below.
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">model.setWhereClause(Expressions.eq("line", 8));</pre>
				<p>
					The following example considers a more complex where-clause. Assume you need to build an expression using logical-and and logical-or:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from ReadyEvent 
where (line=8) or (line=10 and age&lt;5)</pre>
				<p>
					The code for building such a where-clause by means of the object model classes is:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">model.setWhereClause(Expressions.or()
  .add(Expressions.eq("line", 8))
  .add(Expressions.and()
      .add(Expressions.eq("line", 10))
      .add(Expressions.lt("age", 5))
  ));</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-soda-buildingstep3"></a>15.7.3. Building a Pattern Statement</h3>
						</div>
					</div>
				</div>
				<p>
					The <code class="literal">Patterns</code> class is a factory for building pattern expressions. It provides convenient methods to create all pattern expressions of the pattern language.
				</p>
				<p>
					Patterns in EPL are seen as a stream of events that consist of patterns matches. The <code class="literal">PatternStream</code> class represents a stream of pattern matches and contains a pattern expression within.
				</p>
				<p>
					For instance, consider the following pattern statement.
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from pattern [every a=MyAEvent and not b=MyBEvent]</pre>
				<p>
					The next code snippet outlines how to use the statement object model and specifically the <code class="literal">Patterns</code> class to create a statement object model that is equivalent to the pattern statement above.
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setSelectClause(SelectClause.createWildcard());
PatternExpr pattern = Patterns.and()
  .add(Patterns.everyFilter("MyAEvent", "a"))
  .add(Patterns.notFilter("MyBEvent", "b"));
model.setFromClause(FromClause.create(PatternStream.create(pattern)));</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-soda-buildingstep4"></a>15.7.4. Building a Select Statement</h3>
						</div>
					</div>
				</div>
				<p>
					This section builds a complete example statement and includes all optional clauses in one statement, to demonstrate the object model API.
				</p>
				<p>
					A sample statement:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">insert into ReadyStreamAvg(line, avgAge) 
select line, avg(age) as avgAge 
from ReadyEvent(line in (1, 8, 10))#time(10) as RE
where RE.waverId != null
group by line 
having avg(age) &lt; 0
output every 10.0 seconds 
order by line</pre>
				<p>
					Finally, this code snippet builds the above statement from scratch:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setInsertInto(InsertIntoClause.create("ReadyStreamAvg", "line", "avgAge"));
model.setSelectClause(SelectClause.create()
    .add("line")
    .add(Expressions.avg("age"), "avgAge"));
Filter filter = Filter.create("ReadyEvent", Expressions.in("line", 1, 8, 10));
model.setFromClause(FromClause.create(
    FilterStream.create(filter, "RE").addView("win", "time", 10)));
model.setWhereClause(Expressions.isNotNull("RE.waverId"));
model.setGroupByClause(GroupByClause.create("line"));
model.setHavingClause(Expressions.lt(Expressions.avg("age"), Expressions.constant(0)));
model.setOutputLimitClause(OutputLimitClause.create(OutputLimitSelector.DEFAULT, Expressions.timePeriod(null, null, null, 10.0, null)));
model.setOrderByClause(OrderByClause.create("line"));</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-soda-buildingstep5"></a>15.7.5. Building a Create-Variable and On-Set Statement</h3>
						</div>
					</div>
				</div>
				<p>
					This sample statement creates a variable:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create variable integer var_output_rate = 10</pre>
				<p>
					The code to build the above statement using the object model:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setCreateVariable(CreateVariableClause.create("integer", "var_output_rate", 10));</pre>
				<p>
					A second statement sets the variable to a new value:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">on NewValueEvent set var_output_rate = new_rate</pre>
				<p>
					The code to build the above statement using the object model:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setOnExpr(OnClause.createOnSet("var_output_rate", Expressions.property("new_rate")));
model.setFromClause(FromClause.create(FilterStream.create("NewValueEvent")));</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="api-soda-building-step6"></a>15.7.6. Building Create-Window, On-Delete and On-Select Statements</h3>
						</div>
					</div>
				</div>
				<p>
					This sample statement creates a named window:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create window OrdersTimeWindow#time(30 sec) as select symbol as sym, volume as vol, price from OrderEvent</pre>
				<p>
					The is the code that builds the create-window statement as above:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setCreateWindow(CreateWindowClause.create("OrdersTimeWindow").addView("win", "time", 30));
model.setSelectClause(SelectClause.create()
		.addWithName("symbol", "sym")
		.addWithName("volume", "vol")
		.add("price"));
model.setFromClause(FromClause.create(FilterStream.create("OrderEvent)));</pre>
				<p>
					A second statement deletes from the named window:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">on NewOrderEvent as myNewOrders
delete from OrdersNamedWindow as myNamedWindow
where myNamedWindow.symbol = myNewOrders.symbol</pre>
				<p>
					The object model is built by:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setOnExpr(OnClause.createOnDelete("OrdersNamedWindow", "myNamedWindow"));
model.setFromClause(FromClause.create(FilterStream.create("NewOrderEvent", "myNewOrders")));
model.setWhereClause(Expressions.eqProperty("myNamedWindow.symbol", "myNewOrders.symbol"));</pre>
				<p>
					A third statement selects from the named window using the non-continuous on-demand selection via on-select:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">on QueryEvent(volume&gt;0) as query
select count(*) from OrdersNamedWindow as win
where win.symbol = query.symbol</pre>
				<p>
					The on-select statement is built from scratch via the object model as follows:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">EPStatementObjectModel model = new EPStatementObjectModel();
model.setOnExpr(OnClause.createOnSelect("OrdersNamedWindow", "win"));
model.setWhereClause(Expressions.eqProperty("win.symbol", "query.symbol"));
model.setFromClause(FromClause.create(FilterStream.create("QueryEvent", "query", 
  Expressions.gt("volume", 0))));
model.setSelectClause(SelectClause.create().add(Expressions.countStar()));</pre>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-substitution"></a>15.8. Substitution Parameters</h2>
					</div>
				</div>
			</div>
			<p>
				Substitution parameters have the following syntax:
			</p>
			<pre class="synopsis">? [:[<span class="emphasis"><em>name</em></span>] [:<span class="emphasis"><em>type</em></span>]]</pre>
			<p>
				The name is optional. The absence of a name means the substitution parameter is only addressable by index.
			</p>
			<p>
				The type is optional. The absence of the type means the type of the substitution parameter is <code class="literal">java.lang.Object</code>. Use <code class="literal">cast</code> or provide a type name when your expression requires a strongly-typed value.
				The type can also be a parameterized type such as <code class="literal">java.util.List&lt;String&gt;</code>.
			</p>
			<p>
				Here are a few examples of valid substitution parameters:
			</p>
			<div class="table"><a id="apicompiler-substitution-valid"></a>
				<p class="title"><b>Table 15.2. Valid Substitution Parameters</b></p>
				<div class="table-contents">
					<table summary="Valid Substitution Parameters" border="1">
						<colgroup>
							<col>
							<col>
						</colgroup>
						<thead>
							<tr>
								<th>Value</th>
								<th>Description</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td>
									<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">?</pre>
								</td>
								<td>Unnamed and typed <code class="literal">Object</code>.</td>
							</tr>
							<tr>
								<td>
									<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">?::int</pre>
								</td>
								<td>Unnamed and typed <code class="literal">int</code>.</td>
							</tr>
							<tr>
								<td>
									<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">?:param:string</pre>
								</td>
								<td>Named and typed <code class="literal">string</code>.</td>
							</tr>
						</tbody>
					</table>
				</div>
			</div><br class="table-break">
			<p>
				All substitution parameters must either be unnamed or named. It is not possible to mix the two styles.
			</p>
			<p>
				If not assigning a name to substitution parameters, the compiler assigns the first substitution parameter an index of 1 and subsequent parameters increment the index by one.
			</p>
			<p>
				If assigning a name to each substitution parameter, the name can include slash (<code class="literal">/</code>) characters and can occur multiple times.
			</p>
			<p>
				Substitution parameters can be inserted into any EPL construct that takes an expression.
				They are therefore valid in any clauses such as the select-clause, from-clause filters, where-clause, group-by-clause,
				having-clause or order-by-clause, including data window parameters and pattern observers and guards, for example.
				Substitution parameters cannot be used where a numeric constant is required rather than an expression.
			</p>
			<p>
				You may use square brackets (<code class="literal">[]</code>) to denote array-types and <code class="literal">[primitive]</code> for array of primitive. For
				example <code class="literal">int[primitive]</code> for array of <code class="literal">int</code>-primitive and <code class="literal">int[]</code> for array of <code class="literal">Integer</code>.
			</p>
			<p>
				All substitution parameters must be replaced by actual values at time of deployment.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-osgi"></a>15.9. OSGi, Class Loader, Class-For-Name</h2>
					</div>
				</div>
			</div><a id="d0e40995" class="indexterm"></a><a id="d0e41000" class="indexterm"></a><a id="d0e41005" class="indexterm"></a>
			<p>
				The configuration object (<code class="literal">Configuration</code>), in respect to classes, holds the fully-qualified class name and does not generally hold <code class="literal">Class</code> references.
				This is by design since the configuration object can be populated from XML.
			</p>
			<p>
				The compiler may need to look up a class by name and may need to obtain a class loader.
				Your application has full control over class-for-name and classloader use. OSGi environments can provide a specific class-for-name and class loader.
				Please refer to <a class="xref" href="configuration.html#configuration-transientobjects" title="17.7. Passing Services or Transient Objects">Section 17.7, “Passing Services or Transient Objects”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-authoring"></a>15.10. Authoring Tools</h2>
					</div>
				</div>
			</div>
			<p>
				Enterprise Edition includes authoring tools for statements and modules by providing form-based dialogs, templates, an expression builder, simulation tool and other tools. Enterprise Edition also supports hot deployment and packaging options for EPL and related code.
			</p>
			<p>
				Statements can be organized into modules as described above. Any text editor can edit statements and module text. A text editor or IDE that highlights SQL syntax or keywords works.
			</p>
			<p>
				For authoring configuration files please consult the XSD schema files as provided with the distribution.
			</p>
			<p>
				For information on authoring event classes or event definitions in general please see <a class="xref" href="event_representation.html" title="Chapter 3. Event Representations">Chapter 3, <i>Event Representations</i></a> or <a class="xref" href="epl_clauses.html#epl_createschema" title="5.15. Declaring an Event Type: Create Schema">Section 5.15, “Declaring an Event Type: Create Schema”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-testing"></a>15.11. Testing Tools</h2>
					</div>
				</div>
			</div>
			<p>
				We recommend testing modules using a test framework such as JUnit or TestNG. Please consult the regression test suite for extensive examples, which can be downloaded from the distribution site.
			</p>
			<p>
				Esper's API provides test framework classes to simplify automated testing of statements. Please see <a class="xref" href="apiruntime.html#api-testing" title="16.18. Test and Assertion Support">Section 16.18, “Test and Assertion Support”</a> for more information.
			</p>
			<p>
				We recommend performing latency and throughput tests early in the development lifecycle. Please consider the performance tips in <a class="xref" href="performance.html" title="Chapter 24. Performance">Chapter 24, <i>Performance</i></a> for optimal performance.
			</p>
			<p>
				Consider runtime and statement metrics reporting for identifying slow-performing statements, for example. See <a class="xref" href="apiruntime.html#apiruntime-instrumentation" title="16.12. Runtime and Statement Metrics Reporting">Section 16.12, “Runtime and Statement Metrics Reporting”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="devlifecycle-debugging"></a>15.12. Debugging</h2>
					</div>
				</div>
			</div>
			<p>
				Enterprise Edition includes a debugger for module execution.
			</p>
			<p>
				One important tool for debugging without Enterprise Edition is the parameterized <code class="literal">@Audit </code> annotation. This annotation allows to output, on statement-level, detailed information about many aspects of statement processing.
			</p>
			<p>
				Another tool for logging runtime-level detail is <a class="xref" href="configuration.html#configuration-runtime-logging-execpath" title="17.6.2.1. Execution Path Debug Logging">Section 17.6.2.1, “Execution Path Debug Logging”</a>.
			</p>
			<p>
				Please see <a class="xref" href="configuration.html#configuration-logging" title="17.9. Logging Configuration">Section 17.9, “Logging Configuration”</a> for information on configuring logging in general.
			</p>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="devlifecycle-debugging-audit"></a>15.12.1. @Audit Annotation</h3>
						</div>
					</div>
				</div>
				<p>
					Use the <code class="literal">@Audit</code> annotation to have the runtime output detailed information about statement processing. The runtime reports, at INFO level, the information under log name <code class="literal">com.espertech.esper.audit</code>. You may define an output format for audit information via configuration.
				</p>
				<p>
					You may provide a comma-separated list of category names to <code class="literal">@Audit</code> to output information related to specific categories only. The table below lists all available categories. If no parameter is provided, the runtime outputs information for all categories. Category names are not case-sensitive.
				</p>
				<p>
					For the next statement the runtime produces detailed processing information (all categories) for the statement:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@Name('All Order Events') @Audit select * from OrderEvent</pre>
				<p>
					For the next statement the runtime provides information about new events and also about event property values (2 categories are listed):
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@Name('All Order Events') @Audit('stream,property') select price from OrderEvent</pre>
				<p>
					Here is a more complete example that uses the API to create the schema, create above statement and send an event:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">try {
  String module =
    "@public @buseventtype create schema OrderEvent(price double);\n" +
    "@name('All-Order-Events') @Audit('stream,property') select price from OrderEvent;\n";
  EPCompiled compiled = EPCompilerProvider.getCompiler().compile(module, null);

  EPRuntime runtime = EPRuntimeProvider.getDefaultRuntime();
  EPDeployment deployment = runtime.getDeploymentService().deploy(compiled);
  deployment.getStatements()[0].addListener(new SupportUpdateListener());
  runtime.getEventService().sendEventMap(Collections.singletonMap("price", 100d), "OrderEvent");
} catch (Throwable t) {
  log.error(t.getMessage(), t);
}</pre>
				<p>
					The output is similar to the following:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">INFO  [audit] Statement All-Order-Events stream OrderEvent inserted {price=100.0}
INFO  [audit] Statement All-Order-Events property price value 100.0</pre>
				<div class="table"><a id="d0e41104"></a>
					<p class="title"><b>Table 15.3. @Audit Categories</b></p>
					<div class="table-contents">
						<table summary="@Audit Categories" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Category</th>
									<th>Description</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>ContextPartition</td>
									<td>Each context partition allocation and de-allocation (only for statements that declare a context).</td>
								</tr>
								<tr>
									<td>Dataflow-Source</td>
									<td>Each data flow source operator providing an event.</td>
								</tr>
								<tr>
									<td>Dataflow-Op</td>
									<td>Each data flow operator processing an event.</td>
								</tr>
								<tr>
									<td>Dataflow-Transition</td>
									<td>Each data flow instance state transition.</td>
								</tr>
								<tr>
									<td>Exprdef</td>
									<td>Each expression declaration name and return value.</td>
								</tr>
								<tr>
									<td>Expression</td>
									<td>Each top-level expression and its return value.</td>
								</tr>
								<tr>
									<td>Expression-nested</td>
									<td>Each expression including child or nested expressions and their return value.</td>
								</tr>
								<tr>
									<td>Insert</td>
									<td>Each event inserted via insert-into.</td>
								</tr>
								<tr>
									<td>Pattern</td>
									<td>Each pattern sub-expression and its change in truth-value.</td>
								</tr>
								<tr>
									<td>Pattern-instances</td>
									<td>Each pattern sub-expression and its count of active instances.</td>
								</tr>
								<tr>
									<td>Property</td>
									<td>Each property name and the event's property value.</td>
								</tr>
								<tr>
									<td>Schedule</td>
									<td>Each schedule modification and trigger received by a statement.</td>
								</tr>
								<tr>
									<td>Stream</td>
									<td>Each new event received by a statement.</td>
								</tr>
								<tr>
									<td>View</td>
									<td>Each data window name and its insert and remove stream.</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Note that the runtime only evaluates select-clause expressions if either a listener or subscriber is attached to the statement or if used with insert-into.
				</p>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-deploymentorder"></a>15.13. Ordering Multiple Modules</h2>
					</div>
				</div>
			</div>
			<p>
				Since modules may have inter-dependencies as discussed under the <code class="literal">uses</code> declaration, there is a <code class="literal">ModuleOrderUtil</code> class that provides the <code class="literal">getModuleOrder</code> method to order a collection of modules before deployment.
			</p>
			<p>
				Assuming your application reads multiple modules into a <code class="literal">mymodules</code> module list, this code snippet orders the modules for deployment and validates dependency declarations for each module:
			</p>
			<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">List&lt;Module&gt; mymodules =  ... read modules...;  
ModuleOrder order = ModuleOrderUtil.getModuleOrder(mymodules, new ModuleOrderOptions());</pre>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-logging"></a>15.14. Logging</h2>
					</div>
				</div>
			</div>
			<p>
				You can log generated classes at INFO log level by setting the configuration flag for code logging as described in <a class="xref" href="configuration.html#configuration-compiler-logging-code" title="17.5.3.1. Byte Code Generation Logging">Section 17.5.3.1, “Byte Code Generation Logging”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-debugging"></a>15.15. Debugging Generated Code</h2>
					</div>
				</div>
			</div>
			<p>
				The information herein is for developers and is specific to the Janino compiler at the version provided with the distribution.
			</p>
			<p>
				Set the system property <code class="literal">org.codehaus.janino.source_debugging.enable</code> to <code class="literal">true</code> to have Janino compile code with debug symbols.
			</p>
			<p>
				Set the system property <code class="literal">org.codehaus.janino.source_debugging.dir</code> to a file system directory to have Janino generate classes into a given directory.
			</p>
			<p>
				The IDE can debug into generated classes and show the source code provided that the IDE can access the source code. For example:
			</p>
			<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">-Dorg.codehaus.janino.source_debugging.dir=/path/to/directory
-Dorg.codehaus.janino.source_debugging.enable=true</pre>
			<p>
				To include additional EPL-related comments in the generated code you can change the configuration as outlined in <a class="xref" href="configuration.html#configuration-compiler-bytecode" title="17.5.1. Compiler Settings Related to Byte Code Generation">Section 17.5.1, “Compiler Settings Related to Byte Code Generation”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-version"></a>15.16. Compiler Version and Runtime Version</h2>
					</div>
				</div>
			</div>
			<p>
				The version format is <span class="emphasis"><em>major</em></span><code class="literal">.</code><span class="emphasis"><em>minor</em></span><code class="literal">.</code><span class="emphasis"><em>patch-level</em></span>.
			</p>
			<p>
				When deploying a compiled module to a runtime, or when executing a compiled fire-and-forget query, the runtime compares the compiler version that produced the compiled module or compiled query with the runtime version.
				If the major or minor version does not match, the runtime indicates a version mismatch by throwing an exception.
			</p>
			<p>
				For example, an application may compile an EPL module using the version 8.0.0 compiler, i.e. the compiler major version is eight and the compiler minor version is zero and the compiler patch level is zero.
				Assume the application attempts to deploy the compiled module to a runtime of version 8.1.0, i.e. the runtime major version is eight and the runtime minor version is one and the runtime patch level is zero.
				The runtime throws an <code class="literal">EPDeployDeploymentVersionException</code> exception to indicate that the minor version mismatches.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-optimizations"></a>15.17. Compiler Byte Code Optimizations</h2>
					</div>
				</div>
			</div>
			<p>
				The compiler generates byte code that avoids down-casts and branching. It also removes many virtual calls as it transforms expression trees into byte code.
			</p>
			<p>
				For aggregations the compiler produces a custom aggregation row class that has fields which represent the aggregation state. Therefore each aggregation row does not need additional objects to represent aggregations such as averages or sums and
				instead the aggregations are fields of the same class, reducing the number objects that the runtime manages per group-by key.
			</p>
			<p>
				For any composite keys out of two or more expressions the compiler produces a class that represents the composite key and that implements <code class="literal">equals</code> and <code class="literal">hashCode</code>. This is applicable to the <code class="literal">group-by</code> clause including <code class="literal">rollup</code>, data windows with keys (such as <code class="literal">#unique</code>, <code class="literal">#firstunique</code>, <code class="literal">#groupwin</code>, <code class="literal">#rank</code>), <code class="literal">partition-by</code> for keyed segmented contexts, contexts with <code class="literal">distinct</code>, the select-clause <code class="literal">distinct</code> keyword, the query planner when planning implicit and explicit indexes, <code class="literal">create index</code>, <code class="literal">every-distinct</code>, the <code class="literal">partition-by</code> clause for match-recognize, table column keyed-access expressions, the <code class="literal">for</code>-clause for grouped delivery and the <code class="literal">distinctOf</code> enumeration method.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-filterplan"></a>15.18. Compiler Filter Expression Analysis</h2>
					</div>
				</div>
			</div>
			<p>
				The compiler analyzes filter expressions so that the runtime can build filter indexes. For more information on filter indexes please see <a class="xref" href="processingmodel.html#processingmodel_indexes_filterindexes" title="2.18.2. Filter Indexes">Section 2.18.2, “Filter Indexes”</a>.
			</p>
			<p>
				By default the compiler uses advanced techniques for planning filter indexes. Your application may disable some or all of the advanced techniques as described in <a class="xref" href="configuration.html#configuration-compiler-execution-filterindexplanning" title="17.5.8.2. Filter Index Planning">Section 17.5.8.2, “Filter Index Planning”</a>.
			</p>
			<p>
				To output the filter plans please set a compiler flag as described in <a class="xref" href="configuration.html#configuration-compiler-logging-filterplan" title="17.5.3.2. Filter Plan Logging">Section 17.5.3.2, “Filter Plan Logging”</a>.
			</p>
			<div xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="tip">
				<h2>Tip</h2>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>
								Filter indexed planning, like all index planning, reflects a trade-off of amount of space needed for the index, the processing time required to build and maintain an index versus the performance gain of matching incoming events to statements and their partitions
								when there are many (same or different) filters.
							</p>
						</li>
						<li>
							<p>
								The compiler does automatically plan all possible filter indexes. For performance tuning the <code class="literal">ConfigurationCompilerExecution.FilterIndexPlanning.BASIC</code> setting and <code class="literal">ConfigurationCompilerExecution.FilterIndexPlanning.NONE</code> setting and the hints are also available.
							</p>
						</li>
					</ul>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-filterplan-constituentanalysis"></a>15.18.1. Constituent Analysis</h3>
						</div>
					</div>
				</div>
				<p>
					This section applies in the default configuration (<code class="literal">FilterIndexPlanning.ADVANCED</code>) and the non-default <code class="literal">FilterIndexPlanning.BASIC</code> configuation.
				</p>
				<p>
					The compiler analyzes filter expressions by first determining the <span class="emphasis"><em>constituents</em></span>. Constituents are the individual expressions, connected by the <code class="literal">and</code> and <code class="literal">or</code> logical operator, that each return a <code class="literal">boolean</code>-type value and that make up the overall expression.
				</p>
				<p>
					For instance, this EPL statement:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from Withdrawal(accountId = '123' and accountType = 'Checking')</pre>
				<p>
					The constituent expressions are <code class="literal">accountId = '123'</code> and <code class="literal">accountType = 'Checking'</code> (two constituent expressions).
				</p>
				<p>
					The compiler analyzes each constituent expression separately. From a single constituent expression it attempts to form a <span class="emphasis"><em>lookupable-expression</em></span>, <span class="emphasis"><em>filter-index-operator</em></span> and <span class="emphasis"><em>value-expression</em></span> triplet.
					For those constituent expressions that the compiler cannot form a triplet the compiler aggregates such expression into a common boolean expression.
					The remainder of the discussion focuses on a constituent expression and forming a triplet from it.
				</p>
				<p>
					The <span class="emphasis"><em>lookupable-expression</em></span> is the expression providing the filter index lookup value, for example the <code class="literal">accountId</code> expression in <code class="literal">accountId = '123'</code>.
				</p>
				<p>
					The <span class="emphasis"><em>value-expression</em></span> is the expression providing the indexed value, for instance the <code class="literal">'123'</code> expression in <code class="literal">accountId = '123'</code>.
				</p>
				<p>
					The <span class="emphasis"><em>filter-index-operator</em></span> means the type of index such as equals(=), relational (&lt;,&gt;,&lt;=, &gt;=) etc..
				</p>
				<p>
					Therefore, in <code class="literal">Withdrawal(accountId = '123')</code>, the filter-index-operator is <code class="literal">equals</code> and the lookupable-expression is <code class="literal">accountId</code> and the value-expression is <code class="literal">'123'</code>.
				</p>
				<p>
					The expressions that are left and right of a filter-index-operator are commutative, meaning they give the same result whatever the expression occurs on either side of the operator.
					It is equivalent to say <code class="literal">accountId = '123'</code> and <code class="literal">'123' = accountId</code>.
				</p>
				<p>
					The order in which constituent expressions appear does matter. Place the most frequent constituent expressions first. Each filter-index-operator has a precedence level and the compiler orders by precedence level keeping the order as provided within the same precedence level. The precedence levels are, sorted by higher precedence level first, as follows: equal, is, in-list-of-values, advanced-index, range-open, range-half-open, range-half-closed, range-closed, less, less-or-equal, greater-or-equal, greater, not-range-closed, not-range-half-closed, not-range-half-open, not-range-open, not-in-list-of-values, not-equal, is-not.
				</p>
				<p>
					The lookupable-expression in a triplet must be any of the following:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Event property of the arriving event</p>
						</li>
						<li>
							<p>Plug-in single-row node with filter-optimizable setting enabled</p>
						</li>
						<li>
							<p>Declared expression</p>
						</li>
						<li>
							<p>The <code class="literal">typeOf</code> function</p>
						</li>
						<li>
							<p>Other expressions; See hint <a class="xref" href="apicompiler.html#apicompiler-filterplan-hintlkupcomposite" title="15.18.3. Lookupable Composite Expression Analysis">Section 15.18.3, “Lookupable Composite Expression Analysis”</a> for more information.</p>
						</li>
					</ul>
				</div>
				<p>
					The following operators are the triplet filter-index-operator operators. A constituent expression that has one of these operators qualifies for a triplet:
				</p>
				<div class="itemizedlist">
					<ul compact="compact">
						<li>
							<p>
								equals <code class="literal">=</code>
							</p>
						</li>
						<li>
							<p>
								not equals <code class="literal">!=</code>
							</p>
						</li>
						<li>
							<p>
								comparison operators <code class="literal">&lt; , &gt; , &gt;=, &lt;=</code>
							</p>
						</li>
						<li>
							<p>
								ranges
							</p>
							<div class="itemizedlist">
								<ul compact="compact">
									<li>
										<p>
											use the <code class="literal">between</code> keyword for a closed range where both endpoints are included
										</p>
									</li>
									<li>
										<p>
											use the <code class="literal">in </code> keyword and round <code class="literal">()</code> or square brackets <code class="literal">[]</code> to control how endpoints are included
										</p>
									</li>
									<li>
										<p>
											for inverted ranges use the <code class="literal">not</code> keyword and the <code class="literal">between</code> or <code class="literal">in</code> keywords
										</p>
									</li>
								</ul>
							</div>
						</li>
						<li>
							<p>
								list-of-values checks using the <code class="literal">in</code> keyword or the <code class="literal">not in </code> keywords followed by a comma-separated list of values
							</p>
						</li>
						<li>
							<p>
								Other operators; See hint <a class="xref" href="apicompiler.html#apicompiler-filterplan-hintrebool" title="15.18.4. Boolean Reusable Expression Analysis">Section 15.18.4, “Boolean Reusable Expression Analysis”</a> for more information.
							</p>
						</li>
					</ul>
				</div>
				<p>
					The value-expression in a triplet can only be any of the expressions below:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Constant</p>
						</li>
						<li>
							<p>Substitution parameter</p>
						</li>
						<li>
							<p>Event property of a prior-matching event (not the currently arriving event)</p>
						</li>
						<li>
							<p>Context property</p>
						</li>
						<li>
							<p>The <code class="literal">typeOf</code> function</p>
						</li>
						<li>
							<p>Plug-in single-row node with filter-optimizable setting enabled</p>
						</li>
						<li>
							<p>Declared expression</p>
						</li>
						<li>
							<p>Other expressions; See hint <a class="xref" href="apicompiler.html#apicompiler-filterplan-hintvaluecomposite" title="15.18.2. Value Composite Expression Analysis">Section 15.18.2, “Value Composite Expression Analysis”</a> for more information.</p>
						</li>
					</ul>
				</div>
				<p>
					The <code class="literal">or</code> logical operator plays a special role in compiler analysis. The compiler rewrites the expression <code class="literal">accountId = '123' or accountId = '456'</code> to <code class="literal">accountId  in ('123', '456')</code>. It also plans multiple filter index path
					which is further described at <a class="xref" href="configuration.html#configuration-compiler-execution-filterservicemaxfilterwidth" title="17.5.8.1. Filter Service Max Filter Width">Section 17.5.8.1, “Filter Service Max Filter Width”</a>.
				</p>
				<p>
					The order of the triplets, which follows the ordering of the constituents and the ordering according to filter-index-operator precedence level (see above), defines the default nesting of filter indexes.
					The runtime, upon adding to the filter, may however encounter existing filter indexes and always prefers to add to existing filter indexes and following an existing path where possible, or creating new branches and leafs from the existing path.
				</p>
				<p>
					The compiler unwinds logical <code class="literal">and</code> and <code class="literal">or</code> and may also rewind such expressions for planning as below.
					Therefore the expression <code class="literal">a and (b and c)</code> is the same as <code class="literal">a and b and c</code> and the expression <code class="literal">a or (b or c)</code> is the same as <code class="literal">a or b or c</code>.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-filterplan-hintvaluecomposite"></a>15.18.2. Value Composite Expression Analysis</h3>
						</div>
					</div>
				</div>
				<p>
					This section applies to the default configuration (<code class="literal">FilterIndexPlanning.ADVANCED</code>) and also
					when the configuration is <code class="literal">FilterIndexPlanning.BASIC</code> and the EPL contains the <code class="literal">@Hint('filterindex(valuecomposite)')</code> hint.
				</p>
				<p>
					The compiler considers an expression that is meeting certain criteria to be a value-expression provided that there is one of the filter-index-operators as described above.
				</p>
				<p>
					The compiler considers value expressions that are any expression and that do not have any of the following:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Subquery</p>
						</li>
						<li>
							<p>Non-constant variable</p>
						</li>
						<li>
							<p>Event property of the currently-arriving event</p>
						</li>
						<li>
							<p>Expression returning the currently-arriving event i.e. wildcard or stream alias</p>
						</li>
						<li>
							<p>Table access</p>
						</li>
						<li>
							<p>Plug-in single-row node with filter-optimizable setting disabled</p>
						</li>
						<li>
							<p>Lamda expression</p>
						</li>
						<li>
							<p>Declared expression</p>
						</li>
						<li>
							<p><code class="literal">current_timestamp</code> Function</p>
						</li>
					</ul>
				</div>
				<p>
					For example, consider the following EPL statements:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create constant variable string PREFIX = "CHK";
select * from Withdrawal(accountId = PREFIX || '123')</pre>
				<p>
					The expression <code class="literal">PREFIX || '123'</code> is a filter index value-expression and its return value is subject to entry into a filter index as a key.
				</p>
				<p>
					The following example demonstrates the concept further:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
@Hint('filterindex(valuecomposite)')
context TransactionContext select * from Withdrawal(accountId = context.txn.transactionTarget || '-A')</pre>
				<p>
					Assume the following events arrive:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=1, transactionTarget='123')</code>.
							</p>
						</li>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=2, transactionTarget='456')</code>.
							</p>
						</li>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=3, transactionTarget='123')</code>.
							</p>
						</li>
					</ul>
				</div>
				<p>
					The below table is a sample filter index:
				</p>
				<div class="table"><a id="d0e41694"></a>
					<p class="title"><b>Table 15.4. Sample Filter Index</b></p>
					<div class="table-contents">
						<table summary="Sample Filter Index" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Value of <code class="literal">context.txn.transactionTarget || '-A' </code></th>
									<th>Statements and their partitions</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td><code class="literal">'123-A'</code></td>
									<td>Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=1, Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=3</td>
								</tr>
								<tr>
									<td><code class="literal">'456-A'</code></td>
									<td>Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=2</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					When a <code class="literal">Withdrawal</code> event arrives, the runtime evaluates <code class="literal">accountId</code> just once and performs one keyed lookup into the filter index to determine which statements and
					their partitions should process the event.
				</p>
				<p>
					The following example pattern results in equivalent filter index planning:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from pattern[txn=Transaction -&gt; Withdrawal(accountId = txn.transactionTarget || '-A')]</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-filterplan-hintlkupcomposite"></a>15.18.3. Lookupable Composite Expression Analysis</h3>
						</div>
					</div>
				</div>
				<p>
					This section applies to the default configuration (<code class="literal">FilterIndexPlanning.ADVANCED</code>) and also
					when the configuration is <code class="literal">FilterIndexPlanning.BASIC</code> and the EPL contains the <code class="literal">@Hint('filterindex(lkupcomposite)')</code> hint.
				</p>
				<p>
					The compiler considers an expression that is meeting certain criteria to be a lookupable-expression provided that there is one of the filter-index-operators as described above.
				</p>
				<p>
					The lookupable-expression, in any subexpression, must reference at least one event property or the event itself and cannot have any of the following:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Subquery</p>
						</li>
						<li>
							<p>Non-constant variable</p>
						</li>
						<li>
							<p>Context property</p>
						</li>
						<li>
							<p>Table access</p>
						</li>
						<li>
							<p>Plug-in single-row node with filter-optimizable setting disabled</p>
						</li>
						<li>
							<p>Lambda expression</p>
						</li>
						<li>
							<p>Script expression</p>
						</li>
						<li>
							<p>In a pattern, event property of a tagged event, or the tagged event itself (other than self)</p>
						</li>
						<li>
							<p>Method invocation of non-public inlined class</p>
						</li>
					</ul>
				</div>
				<p>
					This hint is usually used when:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Using a context and there are many context partitions</p>
						</li>
						<li>
							<p>Using patterns and there are many active pattern subexpressions</p>
						</li>
						<li>
							<p>There are many statements that have the same filter expression(s)</p>
						</li>
					</ul>
				</div>
				<p>
					Consider the following EPL statement:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from Withdrawal(accountId || accountType = '123Checking')</pre>
				<p>
					The expression <code class="literal">accountId || accountType</code> can serve as a lookupable-expression. The compiler plans a filter index that indexes values such as <code class="literal">'123Checking'</code>
					and that uses the return value of <code class="literal">accountId || accountType</code> to perform a keyed lookup into the indexed values.
				</p>
				<p>
					Extending the example above, please look at the following EPL:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
@Hint('filterindex(lkupcomposite)')
context TransactionContext select * from Withdrawal(accountId || accountType = context.txn.transactionTarget)</pre>
				<p>
					Assume the following events arrive:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=1, transactionTarget='123A')</code>.
							</p>
						</li>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=2, transactionTarget='456B')</code>.
							</p>
						</li>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=3, transactionTarget='123A')</code>.
							</p>
						</li>
					</ul>
				</div>
				<p>
					The below table is a sample filter index:
				</p>
				<div class="table"><a id="d0e41842"></a>
					<p class="title"><b>Table 15.5. Sample Filter Index</b></p>
					<div class="table-contents">
						<table summary="Sample Filter Index" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Value of <code class="literal">context.txn.transactionTarget</code></th>
									<th>Statements and their partitions</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td><code class="literal">'123A'</code></td>
									<td>Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=1, Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=3</td>
								</tr>
								<tr>
									<td><code class="literal">'456B'</code></td>
									<td>Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=2</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					When a <code class="literal">Withdrawal</code> event arrives, the runtime evaluates <code class="literal">accountId || accountType</code> just once and performs one keyed lookup into the filter index to determine which statements and
					their partitions should process the event.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-filterplan-hintrebool"></a>15.18.4. Boolean Reusable Expression Analysis</h3>
						</div>
					</div>
				</div>
				<p>
					This section applies to the default configuration (<code class="literal">FilterIndexPlanning.ADVANCED</code>) and also
					when the configuration is <code class="literal">FilterIndexPlanning.BASIC</code> and the EPL contains the <code class="literal">@Hint('filterindex(boolcomposite)')</code> hint.
				</p>
				<p>
					The compiler considers any expression that is meeting certain criteria to be a reusable boolean expression (does not require any of the filter-index-operators).
				</p>
				<p>
					The expression must not have any of the following:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Subquery</p>
						</li>
						<li>
							<p>Non-constant variable</p>
						</li>
						<li>
							<p>Table access</p>
						</li>
						<li>
							<p>Plug-in single-row node with filter-optimizable setting disabled</p>
						</li>
						<li>
							<p>Lambda expression</p>
						</li>
						<li>
							<p>Method invocation of non-public inlined class</p>
						</li>
						<li>
							<p>Declared expression</p>
						</li>
						<li>
							<p>Chained expression</p>
						</li>
					</ul>
				</div>
				<p>
					The expression must, in any subexpression, reference at least one event property or the event itself. All other expressions must be value-expressions that meet the same requirements as outlined for <code class="literal">valuecomposite</code>.
					The expression may not, in all subexpressions, have multiple value expressions that reference context properties or, in a pattern, event properties of prior events or prior events themselves.
				</p>
				<p>
					Review the following EPL statement:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select * from Withdrawal(accountId regexp '.*123.*')</pre>
				<p>
					The compiler plans a filter index that holds the expression itself and all actual values (determined at runtime, such as <code class="literal">'.*123.*'</code>) and their related statements and partitions.
				</p>
				<p>
					Consider the following wherein <code class="literal">Transaction</code> events have a <code class="literal">regexpFilter</code> field that provides the regexp-right-hand-side value:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
@name('Stmt-1') context TransactionContext select * from Withdrawal(accountId regexp context.txn.regexpFilter)</pre>
				<p>
					Assume the following events arrive:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=1, regexpFilter='.*123.*)</code>.
							</p>
						</li>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=2, regexpFilter='.*456.*)</code>.
							</p>
						</li>
						<li>
							<p>
								<code class="literal">Transaction(transactionId=3, regexpFilter='.*123.*)</code>.
							</p>
						</li>
					</ul>
				</div>
				<p>
					The below table is a sample filter index:
				</p>
				<div class="table"><a id="d0e41976"></a>
					<p class="title"><b>Table 15.6. Sample Filter Index</b></p>
					<div class="table-contents">
						<table summary="Sample Filter Index" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Value of <code class="literal">context.txn.regexpFilter</code></th>
									<th>Statements and their partitions</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td><code class="literal">'.*123.*'</code></td>
									<td>Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=1, Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=3</td>
								</tr>
								<tr>
									<td><code class="literal">'.*456.*'</code></td>
									<td>Statement Stmt-1 Partition <code class="literal">context.txn.transactionId</code>=2</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					When a <code class="literal">Withdrawal</code> event arrives, the runtime evaluates <code class="literal">accountId regexp '.*123.*'</code> and <code class="literal">accountId regexp '.*456.*'</code> both once.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="apicompiler-filterplan-condition"></a>15.18.5. Condition Analysis and Planning</h3>
						</div>
					</div>
				</div>
				<p>
					This section applies to the default configuration (<code class="literal">FilterIndexPlanning.ADVANCED</code>) and also
					when the configuration is <code class="literal">FilterIndexPlanning.BASIC</code> and the EPL contains the <code class="literal">@Hint('filterindex(condition)')</code> hint.
				</p>
				<p>
					The compiler identifies:
				</p>
				<div class="itemizedlist">
					<ul>
						<li>
							<p>Any <span class="emphasis"><em>filter-negating-expression</em></span> expressions.</p>
						</li>
						<li>
							<p>Any <span class="emphasis"><em>filter-confirming-expression</em></span> expressions.</p>
						</li>
						<li>
							<p>Any <span class="emphasis"><em>path-negating-expression</em></span> expressions.</p>
						</li>
						<li>
							<p>Any <span class="emphasis"><em>triplet-confirming-expression</em></span> expressions.</p>
						</li>
					</ul>
				</div>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-filterplan-condition-filternegate"></a>15.18.5.1. Filter-Negating-Expression</h4>
							</div>
						</div>
					</div>
					<p>
						A filter-negating-expression is a value-composite-expression that, when false, negates the filter. An example follows.
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
context TransactionContext select * from Withdrawal(accountId='123' and context.txn.counterparty='A')</pre>
					<p>
						The filter-negating-expression is <code class="literal">context.txn.counterparty='A'</code>. When false the runtime does not look for <code class="literal">Withdrawal</code> events.
					</p>
				</div>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-filterplan-condition-filterconfirm"></a>15.18.5.2. Filter-Confirming-Expression</h4>
							</div>
						</div>
					</div>
					<p>
						A filter-confirm-expression is a value-composite-expression that, when true, means there are no other filter criteria. Here is an example:
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
context TransactionContext select * from Withdrawal(accountId='123' or context.txn.counterparty='A')</pre>
					<p>
						The filter-confirming-expression is <code class="literal">context.txn.counterparty='A'</code>. When true the runtime does not look at the <code class="literal">accountId</code> value of <code class="literal">Withdrawal</code> events.
					</p>
				</div>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-filterplan-condition-pathnegate"></a>15.18.5.3. Path-Negating-Expression</h4>
							</div>
						</div>
					</div>
					<p>
						A path-negating-expression is a value-composite-expression that, when false, negates an alternative, for instance:
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
context TransactionContext select * from Withdrawal(accountId='123' or (accountType='Checking' and context.txn.counterparty='A'))</pre>
					<p>
						The path-negating-expression is <code class="literal">context.txn.counterparty='A'</code>. When false the runtime does not look at the <code class="literal">accountType</code> value of <code class="literal">Withdrawal</code> events.
					</p>
				</div>
				<div class="sect3" lang="en-US">
					<div class="titlepage">
						<div>
							<div>
								<h4 class="title"><a id="apicompiler-filterplan-condition-tripletconfirm"></a>15.18.5.4. Triplet-Confirming-Expression</h4>
							</div>
						</div>
					</div>
					<p>
						A triplet-confirming-expression is a value-composite-expression that, when true, skips a triplet. The example is:
					</p>
					<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create context TransactionContext initiated by Transaction as txn terminated after 10 minutes;
context TransactionContext select * from Withdrawal( (accountId='123' or context.txn.counterparty='A') and (accountType='Checking' or context.txn.counterparty='B'))</pre>
					<p>
						There are two triplet-confirming-expressions. When <code class="literal">context.txn.counterparty='A'</code> is true the runtime does not look at the <code class="literal">accountId</code> value of <code class="literal">Withdrawal</code> events.
						When <code class="literal">context.txn.counterparty='B'</code> is true the runtime does not look at the <code class="literal">accountType</code> value of <code class="literal">Withdrawal</code> events.
					</p>
				</div>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="apicompiler-limitations"></a>15.19. Limitations</h2>
					</div>
				</div>
			</div>
			<p>
				The JVM platform limits the constant pool of classes and method size of methods. The EPL compiler minimizes the chance of stepping over JVM limits, see <a class="xref" href="configuration.html#configuration-compiler-bytecode-general" title="17.5.1.1. Byte Code General Settings">Section 17.5.1.1, “Byte Code General Settings”</a>. This section provides information on known limitations of the EPL compiler.
			</p>
			<p>
				The EPL compiler does not enforce hard limits and this documentation does not list exact limits. Below applies within a single given statement only. Below does not apply across statements and does not apply across modules or the runtime overall.
			</p>
			<p>
				Per statement, there are however limits to compiler processing. Here is a non-comprehensive list of limits per statement:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						<p>Number of expressions in a <code class="literal">group by</code> clause.</p>
					</li>
					<li>
						<p>Number of aggregations.</p>
					</li>
					<li>
						<p>Number of expressions in a <code class="literal">select</code>-clause.</p>
					</li>
					<li>
						<p>Number of property names in an <code class="literal">insert into</code> clause.</p>
					</li>
					<li>
						<p>Number of uniqueness expressions provided to a <code class="literal">#unique</code>, <code class="literal">#firstunique</code> or <code class="literal">#groupwin</code> data window.</p>
					</li>
					<li>
						<p>Number of expressions provided to <code class="literal">for grouped_delivery</code> clause.</p>
					</li>
					<li>
						<p>Number of key expressions in a keyed context, number of hash functions in a hashed context, number of categories in a category context, number of contexts in a nested context.</p>
					</li>
					<li>
						<p>Number of EPL objects consumed or provided by module.</p>
					</li>
					<li>
						<p>Number of inlined-classes, declared expressions, scripts.</p>
					</li>
					<li>
						<p>In patterns, the number of subexpressions to an <code class="literal">and</code>, <code class="literal">or</code>, <code class="literal">-&gt; (followed-by)</code> and the overall number of subexpressions and the number of filter tags.</p>
					</li>
					<li>
						<p>For filter index planning, the number of expressions considered or used by the compiler's filter index planner.</p>
					</li>
					<li>
						<p>For query planning for joins and subqueries, the number of expressions and streams considered or used by the compiler's query planner.</p>
					</li>
					<li>
						<p>Number of streams in the <code class="literal">from</code>-clause.</p>
					</li>
					<li>
						<p>Number of inlined-classes, declared expressions, scripts.</p>
					</li>
					<li>
						<p>For subqueries, the number of subqueries and the number of expressions in the <code class="literal">select</code>-clause of the subquery.</p>
					</li>
					<li>
						<p>For data windows, the number of data windows that are placed in an intersection or union; and the number of additional parameters to statistics views.</p>
					</li>
					<li>
						<p>Number of annotations for a given statement.</p>
					</li>
					<li>
						<p>Number and serialized size of any application-provided user object that is associated to statements or deployments.</p>
					</li>
					<li>
						<p>Number of expressions that are sort criteria in an <code class="literal">order by</code>-clause, or a <code class="literal">#sort</code> or <code class="literal">#rank</code> data window or the <code class="literal">#sorted</code> aggregation.</p>
					</li>
					<li>
						<p>Number of rollup levels for rollup aggregation and the number of group expressions and group levels when provided as an aggregation <code class="literal">group_by:</code> parameter.</p>
					</li>
					<li>
						<p>Number of parameters passed to static methods, instance methods, constructors, user-defined functions, inlined-classes, declared expressions, scripts, subscriber update methods or as parameters within the <code class="literal">from</code>-clause with joins for for accessing relational data via SQL and for accessing non-relational data.</p>
					</li>
					<li>
						<p>Number of sub-expressions that are chained into one expression.</p>
					</li>
					<li>
						<p>Number of event properties that appear chained into one nested event property.</p>
					</li>
					<li>
						<p>For tables, the number of columns and number of aggregations and the number of table primary keys.</p>
					</li>
					<li>
						<p>For named windows, the number of properties.</p>
					</li>
					<li>
						<p>For case control flow (<code class="literal">case</code>), <code class="literal">coalesce</code>, <code class="literal">new</code>, <code class="literal">and</code>, <code class="literal">or</code>, <code class="literal">{}</code> (array expression), <code class="literal">in</code>-keyword, <code class="literal">||</code> (concat), arithmetic, <code class="literal">all</code> and <code class="literal">any</code> the number of sub-expressions.</p>
					</li>
					<li>
						<p>Number of <code class="literal">when matched</code>-clauses and the number of actions in an <code class="literal">on-merge</code>-clause.</p>
					</li>
					<li>
						<p>Number of crontabs wherever multiple crontabs are allowed.</p>
					</li>
					<li>
						<p>For match-recognize, the number of aggregations and the number of variables and the number of pattern elements.</p>
					</li>
					<li>
						<p>Number of <code class="literal">set</code> assignments.</p>
					</li>
					<li>
						<p>Number of variables used by a given statement.</p>
					</li>
					<li>
						<p>Number of properties and number of supertypes in <code class="literal">create schema</code>.</p>
					</li>
					<li>
						<p>Number of columns in <code class="literal">create index</code>.</p>
					</li>
					<li>
						<p>Number of JDBC fields returned by accessing relational data via SQL.</p>
					</li>
					<li>
						<p>For dataflows, the number of types, operators and channels.</p>
					</li>
				</ul>
			</div>
			<p>
				Generally the upper limit for above list is around 1000 for a single statement (this is an estimate). For example, the number of expressions in a <code class="literal">group by</code> clause is limited to somewhere around 1000 expressions or higher for a statement.
			</p>
			<p>
				A statement that has, for example, 100000 expressions in a <code class="literal">group by</code> clause may experience a compiler exception.
			</p>
			<p>
				As part of automated regression testing are tests such as below:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						<p>1000 aggregations including for tables.</p>
					</li>
					<li>
						<p>1000 expressions in the <code class="literal">select</code>-clause (non-subquery) when the output event is map or objectarray.</p>
					</li>
					<li>
						<p><code class="literal">create schema</code> with 1000 properties for map and objectarray event types.</p>
					</li>
					<li>
						<p>1000 substitution parameters.</p>
					</li>
				</ul>
			</div>
		</div>
	</div>
	<ul xmlns:d="http://docbook.org/ns/docbook" class="docnav">
		<li class="previous"><a accesskey="p" href="epl-views.html"><strong>Prev</strong>Chapter 14. EPL Reference: Data Windows</a></li>
		<li class="up"><a accesskey="u" href="#"><strong>Top of page</strong></a></li>
		<li class="home"><a accesskey="h" href="index.html"><strong>Front page</strong></a></li>
		<li class="next"><a accesskey="n" href="apiruntime.html"><strong>Next</strong>Chapter 16. Runtime Reference</a></li>
	</ul>
</body>

</html>